<template>
	<view class="container">
		<!-- 自定义导航栏 -->
		<custom-navbar title="订单详情"></custom-navbar>
		
		<view class="card">
			<view class="code">核销码 MC1234-5678-9012</view>
			<text class="car">车辆:奔驰FWE4/豫A98FHJ</text>
			<view class="line"></view>

			<text class="section">服务内容</text>
			<view class="row between"><text class="item">车辆精洗</text><text class="price">¥100</text></view>
			<view class="row between"><text class="item">车辆精洗附加费</text><text class="price">¥10</text></view>

			<view class="line"></view>
			<text class="section">订单信息</text>
			<view class="row between"><text class="label">原价</text><text class="value">¥110</text></view>
			<view class="row between"><text class="label">优惠</text><text class="value">¥20</text></view>
			<view class="row between"><text class="label">实付金额</text><text class="value">¥90.00</text></view>
			<view class="row between"><text class="label">订单编号</text><text class="value">{{ orderNo || '1223233445' }}</text></view>
			<view class="row between"><text class="label">预约时间</text><text class="value">2023-03-18 19:00:00</text>
			</view>
			<view class="row between"><text class="label">支付时间</text><text class="value">2023-03-18 19:14:28</text>
			</view>
			<view class="row between"><text class="label">核销时间</text></view>
		</view>

		<button class="verify-btn" :class="{ disabled: verified }"
			@click="tryVerify">{{ verified ? '已核销' : '确认核销' }}</button>

		<view class="mask" v-if="showConfirm" @click="showConfirm=false">
			<view class="dialog" @click.stop>
				<text class="dlg-title">核销此订单</text>
				<text class="dlg-sub">请您仔细核对订单，此操作不可撤销
					请谨慎操作！</text>
				<view class="dlg-actions">
					<button class="btn ghost" @click="showConfirm=false">取消</button>
					<button class="btn primary" @click="confirmVerify">确认</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {
			'custom-navbar': () => import('@/components/custom-navbar.vue')
		},
		data() {
			return {
				showConfirm: false,
				verified: false,
				orderId: '',
				orderNo: ''
			};
		},
		onLoad(options) {
			// 接收传递的参数
			if (options.id) {
				this.orderId = options.id;
			}
			if (options.orderNo) {
				this.orderNo = options.orderNo;
			}
			console.log('接收到的订单ID:', this.orderId);
			console.log('接收到的订单号:', this.orderNo);
		},
		methods: {
			tryVerify() {
				if (this.verified) return;
				this.showConfirm = true;
			},
			confirmVerify() {
				this.verified = true;
				this.showConfirm = false;
			}
		}
	}
</script>

<style>
	page {
		background-image: linear-gradient(180deg,
				#2f81fa 0, #2f81fa 35%,
				#f5f5f5 35%, #f5f5f5 100%);
		background-repeat: no-repeat;
	}

	.container {
		padding: 20rpx;
		padding-top: calc(env(safe-area-inset-top) + 88rpx + 20rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 150rpx);
	}

	.card {
		background: #fff;
		border-radius: 20rpx;
		padding: 24rpx;
		box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, .06);
	}

	.code {
		margin-top: 20rpx;
		font-size: 32rpx;
		color: #333333;
		font-weight: bold;
		display: block;
		margin-bottom: 20rpx;
	}

	.car {
		font-size: 28rpx;
		color: #333333;
		display: block;
		margin-bottom: 20rpx;
	}

	.line {
		height: 1rpx;
		background: #e6e8ee;
		margin: 40rpx 0;
	}

	.section {
		font-size: 32rpx;
		color: #333333;
		font-weight: bold;
		display: block;
		margin: 0 0 20rpx;
	}

	.row {
		display: flex;
		align-items: center;
		margin: 20rpx 0;
	}

	.between {
		justify-content: space-between;
	}

	.item {
		font-size: 28rpx;
		color: #333333;
	}

	.price {
		font-size: 28rpx;
		color: #333333;
	}

	.label {
		font-size: 28rpx;
		color: #333333;
	}

	.value {
		font-size: 28rpx;
		color: #333333;
	}

	.value.strong {
		color: #333333;
		font-weight: bold;
		font-size: 32rpx;
	}

	.verify-btn {
		width: calc(100% - 60rpx);
		height: 96rpx;
		line-height: 96rpx;
		border-radius: 48rpx;
		color: #fff;
		background: #0a78ff;
		border: none;
		font-size: 32rpx;
		font-weight: bold;
		position: fixed;
		bottom: calc(env(safe-area-inset-bottom) + 280rpx);
		left: 50%;
		transform: translateX(-50%);
		width: calc(100% - 60rpx);
		max-width: 600rpx;
	}

	.verify-btn.disabled {
		background: #999999;
	}

	.mask {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		background: rgba(0, 0, 0, .4);
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 999;
		
	}

	.dialog {
		width: 600rpx;
		background: #fff;
		border-radius: 20rpx;
		padding: 40rpx;
	
	}

	.dlg-title {
		font-size: 34rpx;
		color: #111;
		font-weight: 600;
		display: block;
		text-align: center;
	}

	.dlg-sub {
		font-size: 28rpx;
		color: #333;
		display: block;
		text-align: center;
		margin: 20rpx 0 30rpx;
		white-space: pre-line;
	}

	.dlg-actions {
		display: flex;
		justify-content: space-between;
		gap: 60rpx;
		
		padding-left: 90rpx;
		padding-right: 90rpx;
		
	}

	.btn {
		flex: 1;
		height: 80rpx;
		line-height: 80rpx;
		border-radius: 44rpx;
		font-size: 30rpx;	
	
	}

	.btn.ghost {
		background: #f0f0f0;
		color: #333;
	}

	.btn.primary {
		background: #0a78ff;
		color: #fff;
	}
</style>